#include <stdio.h>
#include <math.h>

int isPrime(int n)
{
	if (n<=0)return 0;
	if (n == 2 || n==3 || n == 7 || n==5)return 1;
	if (n%2 == 0 || n%3==0 || n == 1)return 0;
	int i;
	for (i=5; i<=floor(sqrt(n)); i +=6) {
		if (n%i == 0)return 0;
		if (n%(i+2) == 0)return 0;
	}
	return 1;
}

int main()
{
	printf("%d\n", isPrime(61));
	int a = -999, b = 2, max = 0, n, fa, fb;
	for (; a<= 999; a+=2) {
		for (b=-999; b<=1000; b+=2) {
			if (isPrime(b)) {
				n = 1;
				while (isPrime(n*n+a*n+b))n++;
				if (n>max) {
					max = n;
					fa = a;
					fb = b;
				}
			}
		}
	}
	printf("%d %d\n", fa*fb, max);
}
